export default class Product {
  // 商品ID，必填
  id: number;

  // 商品名称，必填
  name: string;

  // 商品价格，必填
  price: number;

  // 商品描述，可以为空
  description: Nullable<string> = null;

  // 商品主图URL，可以为空
  imgUrl: Nullable<string> = null;

  // 商品库存数量，必填
  stock: number;

  // 商品分类ID，必填
  categoryId: number;

  // 促销价格，可能不存在，因此标记为Nullable
  promotionalPrice: Nullable<number> = null;

  // 是否上架，可选，默认为true
  isOnSale: boolean = true;

  constructor(id: number, name: string, price: number, stock: number, categoryId: number, 
                description?: string, imgUrl?: string, promotionalPrice?: number, isOnSale?: boolean) {
    this.id = id;
    this.name = name;
    this.price = price;
    this.stock = stock;
    this.categoryId = categoryId;
    this.description = description ?? null;
    this.imgUrl = imgUrl ?? null;
    this.promotionalPrice = promotionalPrice ?? null;
    this.isOnSale = isOnSale ?? true;
  }
}